<%@page import="sysman.SysmanAction"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="../common/taglib.jsp" %> 

<%
	String operate = request.getParameter("operate");
	if("login".equals(operate)) {//登陆
		SysmanAction.login(request);
	} else if("logout".equals(operate)) {//登出
		SysmanAction.logout(request);
	}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="Cache-Control" content="no-cache">
	<title>后台用户登陆</title>
	
	<style type="text/css" media="screen">
		
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td
{
	padding: 0;
	margin: 0;
	font-size: 12px;
	line-height: 100%;
	font-family: Arial, sans-serif;
}

ul,ol {
	list-style: none;
}

img {
	border: 0;
}

body {
	margin: 0;
	text-align: center;
	background: #FFF url(${ctx}/static/images/login_bg.png) repeat-x top;
}

#login {
	display: block;
	width: 950px;
	margin: 0 auto;
	text-align: left;
}

#login_header {
	display: block;
	padding-top: 40px;
	height: 80px;
}

.login_logo {
	float: left;
	margin-top: 10px;
}

.login_info {
	float: left;
	margin-left: 10px;
	line-height: 80px;
	font-size: 18px;
	color: #0088cc;
	font-weight: bold;
}

.login_headerContent {
	float: right;
	display: block;
	width: 280px;
	height: 80px;
	padding: 0 40px;
	background: url(${ctx}/static/images/login_header_bg.png) no-repeat top right;
}

.navList {
	display: block;
	overflow: hidden;
	height: 20px;
	padding-left: 28px;
}

.navList ul {
	float: left;
	display: block;
	overflow: hidden;
}

.navList li {
	float: left;
	display: block;
	margin-left: -1px;
	padding: 0 10px;
	background: url(${ctx}/static/images/login_list.png) no-repeat 0 5px;
}

.navList a {
	display: block;
	white-space: nowrap;
	line-height: 21px;
	color: #000;
	text-decoration: none;
}

.navList a:hover {
	text-decoration: underline;
}

#login_content {
	display: block;
	position: relative;
}

.login_title {
	display: block;
	padding: 25px 0 0 38px;
}

.loginForm {
	display: block;
	width: 240px;
	padding: 40px 20px 0 20px;
	position: absolute;
	right: 280px;
}

.loginForm p {
	margin: 10px 0;
}

.loginForm label {
	float: left;
	width: 60px;
	padding: 0 0 0 10px;
	line-height: 25px;
	color: #4c4c4c;
	font-size: 14px;
}

.loginForm input {
	padding: 3px 2px;
	border-style: solid;
	border-width: 1px;
	border-color: #80a5c4;
}

.loginForm .login_input {
	
}

.loginForm .code {
	float: left;
	margin-right: 5px;
}

.login_bar {
	padding-left: 70px;
}

.login_bar .sub {
	display: block;
	width: 75px;
	height: 30px;
	border: none;
	background: url(${ctx}/static/images/login_sub.png) no-repeat;
	cursor: pointer;
}

.login_banner {
	display: block;
	height: 100px;
}

.login_inner {
	display: block;
	width: 560px;
	padding: 30px 20px 0 20px;
}

.login_inner p {
	margin: 10px 0;
	line-height: 150%;
	font-size: 14px;
	color: #666;
}

#login_footer {
	clear: both;
	display: block;
	margin-bottom: 20px;
	padding: 10px;
	border-top: solid 1px #e2e5e8;
	color: #666;
	text-align: center;
}

	</style>

	<script type="text/javascript">
    function login(){
		 var userName = document.getElementById("USER_CODE").value;
		 if(userName == "") {
			 alert("请输入用户名！");
			 return;
		 }
		 var password = document.getElementById("PASSWORD").value;
		 if(password == "") {
			 alert("请输入密码！");
			 return;
		 }
		 var codeImage = document.getElementById("codeImage").value;
		 if(codeImage == "") {
			 alert("请输入验证码！");
			 return;
		 }
		 
		 var form = document.forms[0];
		 form.action = "${ctx}/admin/login.jsp?operate=login";
		 form.submit();		 
    }
    function loadimage(){ 
    	document.getElementById("randImage").src = "${ctx}/common/codeImage.jsp?rnd="+new Date();   	
    }
    
    if("login" == "<%=operate%>") {
    	if("${ERROR}" == "1") {
    		alert("验证码错误 ,请重新输入 !");
    		document.location.href ="${ctx}/admin/login.jsp";
    	} else if("${ERROR}" == "2" ) {
    		alert("用户名或密码错误 ,请重新输入 !");
    		document.location.href ="${ctx}/admin/login.jsp";
    	} else {
    		//alert("登陆成功");
    		document.location.href ="${ctx}/admin/homepage/main.jsp";
    	}
    }

	</script>
</head>

<body>

	<div id="login">
		
		<!--  
		<div id="login_header">
			<div class="login_banner"><img></img></div>
			<div class="login_info">后 台 管 理</div>
		</div>
		-->
		<div id="login_content">
			<div class="loginForm">

				<form name="loginForm" method="post" action="/admin/login.jsp">

					<p>
						<label><B>用户名：</B></label> <input type="text" id="USER_CODE" name="USER_CODE"
							size="20" class="login_input" />
					</p>
					<p>
						<label><B>密码：</B></label> <input id="PASSWORD" name="PASSWORD"
							type="password" size="20" class="login_input" />
					</p>
					<p>
						<label><B>验证码：</B></label> <input class="code" type="text"
							maxlength="4" id="codeImage" name="codeImage" size="5" /> <span>
							<img alt="" name="randImage" id="randImage" src="${ctx}/common/codeImage.jsp" width="75" height="24" border="1" align="absmiddle" onclick="loadimage()">
						</span>
					</p>
					<div class="login_bar">
						<input class="sub" type="button" value=" " onclick="login()" />
					</div>
				</form>
			</div>
		</div>
	</div>

</body>
</html>
